<%--
  Created by IntelliJ IDEA.
  User: chinalin
  Date: 2017/3/23
  Time: 14:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    pageContext.setAttribute("BASE",path);
%>

<head>
    <title>客户管理 - 创建客户</title>
    <script src="${BASE}/asset/lib/jquery/jquery-3.1.1.min.js" type="text/javascript"></script>
    <script src="${BASE}/asset/lib/jquery-form/jquery.form.js" type="text/javascript"></script>
    <%--<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>--%>
    <%--<script src="https://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js"></script>--%>
</head>
<body>
    <h1>创建客户界面</h1>
<form id="customer_form" enctype="multipart/form-data" method="post">
<%--<form id="customer_form" >--%>
    <table>
        <tr>
            <td>客户名称：</td>
            <td>
                <input type="text" name="name" value="${customer.name}">
            </td>
        </tr>
        <tr>
            <td>联系人：</td>
            <td>
                <input type="text" name="contact" value="${customer.contact}">
            </td>
        </tr>
        <tr>
            <td>电话号码：</td>
            <td>
                <input type="text" name="telephone" value="${customer.telephone}">
            </td>
        </tr>
        <tr>
            <td>邮箱地址：</td>
            <td>
                <input type="text" name="email" value="${customer.email}">
            </td>
        </tr>
        <tr>
            <td>照片：</td>
            <td>
                <input type="file" name="photo" multiple="multiple" value="${customer.photo}">
            </td>
        </tr>
        爱    好:<input type="checkbox" name="hobby" value="吃饭" />吃饭
        <input type="checkbox" name="hobby" value="睡觉" />睡觉
        <input type="checkbox" name="hobby" value="打代码" />打代码
    </table>
    <button type="submit">保存</button>
</form>
<script>
    $(function () {                                                         /*  等同于$(document).ready(function(){  */
        $('#customer_form').ajaxForm({
//            type:'post',
            url:'${BASE}/customer_create',
            success: function (data) {
                if (data){
                    location.href = '${BASE}/customer' ;
                }
            }
        });
    });
</script>
</body>
</html>
